import asyncio


async def read_file_async(file_path):
    async with open(file_path, 'r') as file:
        data = await file.read()
        return data


async def write_file_async(file_path, data):
    async with open(file_path, 'w') as file:
        await file.write(data)


# 使用示例
async def main():
    example_file_path = '/Users/hemq/PycharmProjects/LocalFastApi/sql_app/asynicFileWrite/example.txt'
    example_copy_file_path = '/Users/hemq/PycharmProjects/LocalFastApi/sql_app/asynicFileWrite/example_copy.txt'
    data = await read_file_async(example_file_path)
    await write_file_async(example_copy_file_path, data)


asyncio.run(main())
